<template>
    <div class="header">
        <div :class="{ 'cq-header': isIndex, 'cq-header-white': !isIndex }">
            <div class="full-center w1160">
                <div class="left-img">
                    <img :src="$get(isIndex ?'logofanbai' : 'logo')" alt="white-logo">
                </div>
                <ul class="right-list fz16">
                    <li class="outside" v-for="item in NavList" :key="item.id">
                        <div v-if="item.children && item.children.length">
                            <a href="#">{{ item.linkName }}</a>
                            <img :src="$get('arrow-down')" alt="down">
                            <div class="mask-box">
                                <ul>
                                    <li v-for="i in item.children" :key="i.id">
                                        <router-link :to="i.url">{{ i.linkName }}</router-link>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <router-link v-else :to="item.url">{{ item.linkName }}</router-link>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>
// :class="{active: $route.path === item.url}"
<script>
export default {
  name: 'CqHeader',
  data () {
    return {
      NavList: [
        { id: 1, url: '/index', linkName: '首页' },
        {
          id: 2,
          url: '/brand',
          linkName: '橙品牌',
          children: [
            { id: 1, url: '/news', linkName: '新闻资讯' },
            { id: 2, url: '/apply', linkName: '入驻申请' }
          ]
        },
        { id: 3, url: '/news', linkName: '新闻资讯' },
        { id: 4, url: '/apply', linkName: '入驻申请' },
        { id: 5, url: '/case', linkName: '行业案例' },
        { id: 6, url: '/about', linkName: '关于我们' }
      ]
    }
  },
  computed: {
    isIndex () {
      return this.$route.path === '/index'
    }
  }
}
</script>

<style lang="scss" scoped>
$blue: #22a4ec;
.cq-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 999;
    padding: 22px 0;
    .full-center {
      display: flex;
      justify-content: space-between;
      line-height: 36px;
    }
}
.cq-header-white {
    display: flex;
    align-items: center;
    height: 80px;
    background-color: #fff;
    .full-center {
      display: flex;
      justify-content: space-between;
      line-height: 36px;
    }
}

.right-list {
    display: flex;
    position: relative;
    .outside {
        margin-right: 45px;
        a {
            color: #c8c8c8;
            &:hover {
                color: $blue;
            }
        }
        .router-link-active {
            color: $blue;
        }
    }
    li:nth-child(2) {
        img {
            width: 10px;
            margin-left: 10px;
            transition: .3s;
        }
        &:hover .mask-box {
            max-height: 500px;
        }
        &:hover img {
            transform: rotate(180deg);
        }
    }
}

.mask-box {
    position: absolute;
    top: 25px;
    left: 56px;
    display: flex;
    flex-direction: column;
    width: 100px;
    max-height: 0;
    margin-top: 20px;
    overflow: hidden;
    text-align: center;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.5);
    transition: max-height .3s ease-in-out;
    li {
        padding: 5px;
    }
}

</style>
